+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
+Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_class_init): Fix
+ G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
+ stupidity.
+
+Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ First pass at adding style properties. Still needs some definite
+ fine-tuning. ]
+
+ * gtk/gtkbutton.c: Add ::default_spacing style property.
+
+ * gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
+ ::indicator_spacing style properties.
+
+ * gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
+ style properties.
+
+ * gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
+ rather than a normal property.
+
+ * gtk/gtkwidget.c: Add an ::interior_focus style property to
+ draw focus inside buttons, in the Windows/Java Metal/etc. style.
+
+ * gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
+ Honor ::interior_focus.
+
+ * gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
+ TRUE.
+
+ * gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
+ Add ::slider_width, ::trough_border, ::stepper_size,
+ ::stepper_spacing style properties.
+
+ * gtk/gtkscale.[ch] Add ::slider-length style property.
+
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
#include "gtkintl.h"
#define CHILD_SPACING 1
-#define DEFAULT_LEFT_POS 4
-#define DEFAULT_TOP_POS 4
#define DEFAULT_SPACING 7
/* Time out before giving up on getting a key release when animatng
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
widget_class->activate_signal = button_signals[ACTIVATE];
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("default_spacing",
+ _("Default Spacing"),
+ _("Extra space to add for CAN_DEFAULT buttons"),
+ 0,
+ G_MAXINT,
+ DEFAULT_SPACING,
+ G_PARAM_READABLE));
}
static void
}
static void
-gtk_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gtk_button_get_props (GtkButton *button,
+ gint *default_spacing,
+ gboolean *interior_focus)
{
- GtkButton *button;
+ GtkWidget *widget = GTK_WIDGET (button);
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_BUTTON (widget));
- g_return_if_fail (requisition != NULL);
+ if (default_spacing)
+ gtk_widget_style_get (widget, "default_spacing", default_spacing, NULL);
- button = GTK_BUTTON (widget);
+ if (interior_focus)
+ gtk_widget_style_get (widget, "interior_focus", interior_focus, NULL);
+}
+
+static void
+gtk_button_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkButton *button = GTK_BUTTON (widget);
+ gint default_spacing;
+ gboolean interior_focus;
+ gtk_button_get_props (button, &default_spacing, &interior_focus);
+
requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
GTK_WIDGET (widget)->style->xthickness) * 2;
requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 +
- DEFAULT_SPACING);
+ default_spacing);
requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 +
- DEFAULT_SPACING);
+ default_spacing);
}
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
+
+ if (interior_focus)
+ {
+ requisition->width += 2;
+ requisition->height += 2;
+ }
}
static void
gtk_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkButton *button;
+ GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
- gint border_width;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_BUTTON (widget));
- g_return_if_fail (allocation != NULL);
+ gint border_width = GTK_CONTAINER (widget)->border_width;
+ gint xthickness = GTK_WIDGET (widget)->style->xthickness;
+ gint ythickness = GTK_WIDGET (widget)->style->ythickness;
+ gint default_spacing;
+ gtk_button_get_props (button, &default_spacing, NULL);
+
widget->allocation = *allocation;
- border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
widget->allocation.width - border_width * 2,
widget->allocation.height - border_width * 2);
- button = GTK_BUTTON (widget);
-
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
- child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->xthickness);
- child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->ythickness);
+ child_allocation.x = (CHILD_SPACING + xthickness);
+ child_allocation.y = (CHILD_SPACING + ythickness);
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
border_width * 2);
if (GTK_WIDGET_CAN_DEFAULT (button))
{
child_allocation.x += (GTK_WIDGET (widget)->style->xthickness +
- DEFAULT_LEFT_POS);
+ (1 + default_spacing) / 2);
child_allocation.y += (GTK_WIDGET (widget)->style->ythickness +
- DEFAULT_TOP_POS);
+ (1 + default_spacing) / 2);
child_allocation.width = MAX (1, (gint)child_allocation.width -
- (gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
+ (gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
child_allocation.height = MAX (1, (gint)child_allocation.height -
- (gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
+ (gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
}
gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
GtkShadowType shadow_type;
gint width, height;
gint x, y;
+ gint default_spacing;
+ gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget))
{
button = GTK_BUTTON (widget);
+
+ gtk_button_get_props (button, &default_spacing, &interior_focus);
x = 0;
y = 0;
{
x += widget->style->xthickness;
y += widget->style->ythickness;
- width -= 2 * x + DEFAULT_SPACING;
- height -= 2 * y + DEFAULT_SPACING;
- x += DEFAULT_LEFT_POS;
- y += DEFAULT_TOP_POS;
+ width -= 2 * x + default_spacing;
+ height -= 2 * y + default_spacing;
+ x += (1 + default_spacing) / 2;
+ y += (1 + default_spacing) / 2;
}
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
{
x += 1;
y += 1;
if (GTK_WIDGET_HAS_FOCUS (widget))
{
- x -= 1;
- y -= 1;
- width += 2;
- height += 2;
+ if (interior_focus)
+ {
+ x += widget->style->xthickness + 1;
+ y += widget->style->ythickness + 1;
+ width -= 2 * (widget->style->xthickness + 1);
+ height -= 2 * (widget->style->xthickness + 1);
+ }
+ else
+ {
+ x -= 1;
+ y -= 1;
+ width += 2;
+ height += 2;
+ }
gtk_paint_focus (widget->style, widget->window,
area, widget, "button",
*/
#include "gtkcheckbutton.h"
+#include "gtkintl.h"
#include "gtklabel.h"
widget_class->size_request = gtk_check_button_size_request;
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->expose_event = gtk_check_button_expose;
-
- class->indicator_size = INDICATOR_SIZE;
- class->indicator_spacing = INDICATOR_SPACING;
+
class->draw_indicator = gtk_real_check_button_draw_indicator;
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("indicator_size",
+ _("Indicator Size"),
+ _("Size of check or radio indicator"),
+ 0,
+ G_MAXINT,
+ INDICATOR_SIZE,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("indicator_spacing",
+ _("Indicator Spacing"),
+ _("Spacing around check or radio indicator"),
+ 0,
+ G_MAXINT,
+ INDICATOR_SPACING,
+ G_PARAM_READABLE));
}
static void
gtk_check_button_paint (GtkWidget *widget,
GdkRectangle *area)
{
- GtkCheckButton *check_button;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
-
- check_button = GTK_CHECK_BUTTON (widget);
+ GtkCheckButton *check_button = GTK_CHECK_BUTTON (widget);
if (GTK_WIDGET_DRAWABLE (widget))
{
gint border_width;
+ gint interior_focus;
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
gtk_check_button_draw_indicator (check_button, area);
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_HAS_FOCUS (widget))
- gtk_paint_focus (widget->style, widget->window,
- NULL, widget, "checkbutton",
- border_width + widget->allocation.x,
- border_width + widget->allocation.y,
- widget->allocation.width - 2 * border_width - 1,
- widget->allocation.height - 2 * border_width - 1);
+ {
+ if (interior_focus)
+ {
+ GtkWidget *child = GTK_BIN (widget)->child;
+
+ if (child && GTK_WIDGET_VISIBLE (child))
+ gtk_paint_focus (widget->style, widget->window,
+ NULL, widget, "checkbutton",
+ child->allocation.x - 1,
+ child->allocation.y - 1,
+ child->allocation.width + 1,
+ child->allocation.height + 1);
+ }
+ else
+ gtk_paint_focus (widget->style, widget->window,
+ NULL, widget, "checkbutton",
+ border_width + widget->allocation.x,
+ border_width + widget->allocation.y,
+ widget->allocation.width - 2 * border_width - 1,
+ widget->allocation.height - 2 * border_width - 1);
+ }
}
}
+void
+_gtk_check_button_get_props (GtkCheckButton *check_button,
+ gint *indicator_size,
+ gint *indicator_spacing)
+{
+ GtkWidget *widget = GTK_WIDGET (check_button);
+
+ if (indicator_size)
+ gtk_widget_style_get (widget, "indicator_size", indicator_size, NULL);
+
+ if (indicator_spacing)
+ gtk_widget_style_get (widget, "indicator_spacing", indicator_spacing, NULL);
+}
+
static void
gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkToggleButton *toggle_button;
- gint temp;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
toggle_button = GTK_TOGGLE_BUTTON (widget);
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
if (toggle_button->draw_indicator)
{
- requisition->width += (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 2);
+ GtkWidget *child;
+ gint temp;
+ gint indicator_size;
+ gint indicator_spacing;
+ gint border_width = GTK_CONTAINER (widget)->border_width;
+
+ requisition->width = border_width + 2;
+ requisition->height = border_width + 2;
+
+ child = GTK_BIN (widget)->child;
+ if (child && GTK_WIDGET_VISIBLE (child))
+ {
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (child, &child_requisition);
+
+ requisition->width += child_requisition.width;
+ requisition->height += child_requisition.height;
+ }
+
+ _gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
+ &indicator_size, &indicator_spacing);
- temp = (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 2);
+ requisition->width += (indicator_size + indicator_spacing * 3 + 2);
+
+ temp = (indicator_size + indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2;
}
+ else
+ (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
}
static void
if (toggle_button->draw_indicator)
{
+ gint indicator_size;
+ gint indicator_spacing;
+
+ _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
+
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (toggle_button->event_window,
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
- child_allocation.x = (GTK_CONTAINER (widget)->border_width +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1 +
+ gint border_width = GTK_CONTAINER (widget)->border_width;
+
+ child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + 1 +
widget->allocation.x);
- child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 +
- widget->allocation.y;
+ child_allocation.y = border_width + 1 + widget->allocation.y;
child_allocation.width = MAX (1, allocation->width -
- (GTK_CONTAINER (widget)->border_width +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
- GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1) -
- GTK_CONTAINER (widget)->border_width - 1);
- child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2);
+ (border_width + indicator_size + indicator_spacing * 3 + 1) -
+ border_width - 1);
+ child_allocation.height = MAX (1, allocation->height - (border_width + 1) * 2);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + allocation->width
}
}
else
- {
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
- }
+ (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
}
static gint
GdkRectangle new_area;
gint width, height;
gint x, y;
+ gint indicator_size;
+ gint indicator_spacing;
GdkWindow *window;
g_return_if_fail (check_button != NULL);
{
window = widget->window;
+ _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
+
state_type = GTK_WIDGET_STATE (widget);
if (state_type != GTK_STATE_NORMAL &&
state_type != GTK_STATE_PRELIGHT)
new_area.width, new_area.height);
}
- x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
- width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
- height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
+ x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
+ y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
+ width = indicator_size;
+ height = indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
{
{
GtkToggleButtonClass parent_class;
- guint16 indicator_size;
- guint16 indicator_spacing;
-
void (* draw_indicator) (GtkCheckButton *check_button,
GdkRectangle *area);
};
GtkWidget* gtk_check_button_new_with_label (const gchar *label);
GtkWidget* gtk_check_button_new_with_mnemonic (const gchar *label);
+void _gtk_check_button_get_props (GtkCheckButton *check_button,
+ gint *indicator_size,
+ gint *indicator_spacing);
#ifdef __cplusplus
}
{
gint width, height;
GtkEntry *entry;
+ gboolean interior_focus;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
entry = GTK_ENTRY (widget);
if (GTK_WIDGET_DRAWABLE (widget))
gdk_window_get_size (widget->window, &width, &height);
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
x += 1;
y += 1;
height -= 2;
}
-
gtk_paint_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
NULL, widget, "entry",
else
gdk_window_clear (widget->window);
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
gdk_window_get_size (widget->window, &width, &height);
gtk_paint_focus (widget->style, widget->window,
gtk_hpaned_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child_requisition;
+ gint handle_size;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_HPANED (widget));
- g_return_if_fail (requisition != NULL);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
- paned = GTK_PANED (widget);
requisition->width = 0;
requisition->height = 0;
requisition->width += child_requisition.width;
}
- requisition->width += GTK_CONTAINER (paned)->border_width * 2 + paned->handle_size;
+ requisition->width += GTK_CONTAINER (paned)->border_width * 2 + handle_size;
requisition->height += GTK_CONTAINER (paned)->border_width * 2;
}
gtk_hpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
+ gint border_width = GTK_CONTAINER (paned)->border_width;
+ gint handle_size;
GtkRequisition child1_requisition;
GtkRequisition child2_requisition;
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
- gint border_width;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_HPANED (widget));
- g_return_if_fail (allocation != NULL);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
widget->allocation = *allocation;
- paned = GTK_PANED (widget);
- border_width = GTK_CONTAINER (paned)->border_width;
if (paned->child1)
gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
child2_requisition.width = 0;
gtk_paned_compute_position (paned,
- MAX (1, (gint) widget->allocation.width
- - (gint) paned->handle_size
+ MAX (1, widget->allocation.width
+ - handle_size
- 2 * border_width),
child1_requisition.width,
child2_requisition.width);
paned->handle_xpos = paned->child1_size + border_width;
paned->handle_ypos = border_width;
- paned->handle_width = paned->handle_size;
- paned->handle_height = MAX (1, (gint) widget->allocation.height - 2 * border_width);
+ paned->handle_width = handle_size;
+ paned->handle_height = MAX (1, widget->allocation.height - 2 * border_width);
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_move_resize (paned->handle,
paned->handle_xpos,
paned->handle_ypos,
- paned->handle_size,
+ handle_size,
paned->handle_height);
}
GtkWidget *widget;
GdkGCValues values;
guint16 xpos;
+ gint handle_size;
- widget = GTK_WIDGET(paned);
+ widget = GTK_WIDGET (paned);
+
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->xor_gc)
{
GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
xpos = paned->child1_size
- + GTK_CONTAINER (paned)->border_width + paned->handle_size / 2;
+ + GTK_CONTAINER (paned)->border_width + handle_size / 2;
gdk_draw_line (widget->window, paned->xor_gc,
xpos,
gtk_hpaned_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
+ gint handle_size;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
-
- paned = GTK_PANED (widget);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->in_drag &&
event->window == paned->handle && event->button == 1)
| GDK_BUTTON1_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
NULL, NULL, event->time);
- paned->child1_size += event->x - paned->handle_size / 2;
+ paned->child1_size += event->x - handle_size / 2;
paned->child1_size = CLAMP (paned->child1_size, 0,
widget->allocation.width
- - paned->handle_size
+ - handle_size
- 2 * GTK_CONTAINER (paned)->border_width);
gtk_hpaned_xor_line (paned);
gtk_hpaned_motion (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
gint x;
+ gint handle_size;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
-
- paned = GTK_PANED (widget);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (event->is_hint || event->window != widget->window)
gtk_widget_get_pointer(widget, &x, NULL);
if (paned->in_drag)
{
- gint size = x - GTK_CONTAINER (paned)->border_width - paned->handle_size / 2;
+ gint size = x - GTK_CONTAINER (paned)->border_width - handle_size / 2;
gtk_hpaned_xor_line (paned);
paned->child1_size = CLAMP (size, paned->min_position, paned->max_position);
GdkWindowAttr attributes;
gint attributes_mask;
gint x, y, w, h;
+ gint slider_width, slider_length;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCALE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
+
+ _gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
+ gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
- attributes.width = SCALE_CLASS (range)->slider_length;
- attributes.height = RANGE_CLASS (range)->slider_width;
+ attributes.width = slider_length;
+ attributes.height = slider_width;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
gtk_hscale_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkScale *scale;
+ GtkScale *scale = GTK_SCALE (widget);
+ gint slider_width, slider_length, trough_border;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCALE (widget));
g_return_if_fail (requisition != NULL);
- scale = GTK_SCALE (widget);
-
- requisition->width = (SCALE_CLASS (scale)->slider_length +
- widget->style->xthickness) * 2;
- requisition->height = (RANGE_CLASS (scale)->slider_width +
- widget->style->ythickness * 2);
+ _gtk_range_get_props (GTK_RANGE (scale),
+ &slider_width, &trough_border, NULL, NULL);
+ gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
+
+ requisition->width = (slider_length + trough_border) * 2;
+ requisition->height = (slider_width + trough_border * 2);
if (scale->draw_value)
{
gint *w,
gint *h)
{
- GtkWidget *widget;
- GtkScale *scale;
+ GtkWidget *widget = GTK_WIDGET (hscale);
+ GtkScale *scale = GTK_SCALE (hscale);
+ gint slider_width;
+ gint trough_border;
- g_return_if_fail (hscale != NULL);
- g_return_if_fail (GTK_IS_HSCALE (hscale));
- g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
-
- widget = GTK_WIDGET (hscale);
- scale = GTK_SCALE (hscale);
+ _gtk_range_get_props (GTK_RANGE (scale),
+ &slider_width, &trough_border, NULL, NULL);
*w = widget->allocation.width;
- *h = (RANGE_CLASS (scale)->slider_width +
- widget->style->ythickness * 2);
+ *h = (slider_width + trough_border * 2);
if (scale->draw_value)
{
const GValue *value,
GParamSpec *pspec);
static void gtk_hscrollbar_realize (GtkWidget *widget);
+static void gtk_hscrollbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
static void gtk_hscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_hscrollbar_draw_step_forw (GtkRange *range);
GtkScrollType *scroll,
GtkTroughType *pos);
-
GtkType
gtk_hscrollbar_get_type (void)
{
gobject_class->get_property = gtk_hscrollbar_get_property;
widget_class->realize = gtk_hscrollbar_realize;
+ widget_class->size_request = gtk_hscrollbar_size_request;
widget_class->size_allocate = gtk_hscrollbar_size_allocate;
range_class->draw_step_forw = gtk_hscrollbar_draw_step_forw;
static void
gtk_hscrollbar_init (GtkHScrollbar *hscrollbar)
{
- GtkWidget *widget;
- GtkRequisition *requisition;
-
- widget = GTK_WIDGET (hscrollbar);
- requisition = &widget->requisition;
-
- requisition->width = (RANGE_CLASS (widget)->min_slider_size +
- RANGE_CLASS (widget)->stepper_size +
- RANGE_CLASS (widget)->stepper_slider_spacing +
- widget->style->xthickness) * 2;
- requisition->height = (RANGE_CLASS (widget)->slider_width +
- widget->style->ythickness * 2);
}
GtkWidget*
GtkRange *range;
GdkWindowAttr attributes;
gint attributes_mask;
+ gint slider_width;
+ gint trough_border;
+ gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
+ _gtk_range_get_props (range, &slider_width, &trough_border,
+ &stepper_size, NULL);
+
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y + (widget->allocation.height - widget->requisition.height) / 2;
attributes.width = widget->allocation.width;
range->trough = widget->window;
gdk_window_ref (range->trough);
- attributes.x = widget->style->xthickness;
- attributes.y = widget->style->ythickness;
- attributes.width = RANGE_CLASS (widget)->stepper_size;
- attributes.height = RANGE_CLASS (widget)->stepper_size;
+ attributes.x = trough_border;
+ attributes.y = trough_border;
+ attributes.width = stepper_size;
+ attributes.height = stepper_size;
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.x = (widget->allocation.width -
- widget->style->xthickness -
- RANGE_CLASS (widget)->stepper_size);
+ trough_border -
+ stepper_size);
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.x = 0;
- attributes.y = widget->style->ythickness;
+ attributes.y = trough_border;
attributes.width = RANGE_CLASS (widget)->min_slider_size;
- attributes.height = RANGE_CLASS (widget)->slider_width;
+ attributes.height = slider_width;
+
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
gdk_window_show (range->step_back);
}
+static void
+gtk_hscrollbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ gint slider_width;
+ gint trough_border;
+ gint stepper_size;
+ gint stepper_spacing;
+
+ GtkRange *range = GTK_RANGE (widget);
+
+ _gtk_range_get_props (range, &slider_width, &trough_border,
+ &stepper_size, &stepper_spacing);
+
+ requisition->width = (RANGE_CLASS (widget)->min_slider_size +
+ stepper_size +
+ stepper_spacing +
+ trough_border) * 2;
+ requisition->height = (slider_width +
+ trough_border * 2);
+}
+
static void
gtk_hscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkRange *range;
+ gint trough_border;
+ gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
{
range = GTK_RANGE (widget);
+ _gtk_range_get_props (range, NULL, &trough_border,
+ &stepper_size, NULL);
+
gdk_window_move_resize (range->trough,
allocation->x,
allocation->y + (allocation->height - widget->requisition.height) / 2,
allocation->width, widget->requisition.height);
gdk_window_move_resize (range->step_back,
- widget->style->xthickness,
- widget->style->ythickness,
- RANGE_CLASS (widget)->stepper_size,
- widget->requisition.height - widget->style->ythickness * 2);
+ trough_border,
+ trough_border,
+ stepper_size,
+ widget->requisition.height - trough_border * 2);
gdk_window_move_resize (range->step_forw,
- allocation->width - widget->style->xthickness -
- RANGE_CLASS (widget)->stepper_size,
- widget->style->ythickness,
- RANGE_CLASS (widget)->stepper_size,
- widget->requisition.height - widget->style->ythickness * 2);
+ allocation->width - trough_border -
+ stepper_size,
+ trough_border,
+ stepper_size,
+ widget->requisition.height - trough_border * 2);
_gtk_range_slider_update (GTK_RANGE (widget));
}
gint step_forw_x;
gint slider_width;
gint slider_height;
+ gint stepper_spacing;
gint left, right;
gint width;
g_return_if_fail (hscrollbar != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (hscrollbar));
-
+
if (GTK_WIDGET_REALIZED (hscrollbar))
{
range = GTK_RANGE (hscrollbar);
+
+ _gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
gdk_window_get_size (range->step_back, &step_back_width, NULL);
gdk_window_get_position (range->step_back, &step_back_x, NULL);
left = (step_back_x +
step_back_width +
- RANGE_CLASS (hscrollbar)->stepper_slider_spacing);
- right = step_forw_x - RANGE_CLASS (hscrollbar)->stepper_slider_spacing;
+ stepper_spacing);
+ right = step_forw_x - stepper_spacing;
width = right - left;
if ((range->adjustment->page_size > 0) &&
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "gtkintl.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtkoptionmenu.h"
#define CHILD_RIGHT_SPACING 1
#define CHILD_TOP_SPACING 1
#define CHILD_BOTTOM_SPACING 1
-#define OPTION_INDICATOR_WIDTH 12
-#define OPTION_INDICATOR_HEIGHT 8
-#define OPTION_INDICATOR_SPACING 2
+typedef struct _GtkOptionMenuProps GtkOptionMenuProps;
+
+struct _GtkOptionMenuProps
+{
+ GtkRequisition indicator_size;
+ GtkBorder indicator_spacing;
+};
+
+static GtkOptionMenuProps default_props = {
+ { 12, 8 },
+ { 3, 7, 2, 2 } /* Left, right, top, bottom */
+};
static void gtk_option_menu_class_init (GtkOptionMenuClass *klass);
static void gtk_option_menu_init (GtkOptionMenu *option_menu);
widget_class->hide_all = gtk_option_menu_hide_all;
container_class->child_type = gtk_option_menu_child_type;
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("indicator_size",
+ _("Indicator Size"),
+ _("Size of dropdown indicator"),
+ GTK_TYPE_REQUISITION,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("indicator_spacing",
+ _("Indicator Spacing"),
+ _("Spacing around indicator"),
+ GTK_TYPE_BORDER,
+ G_PARAM_READABLE));
}
static GtkType
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
+static void
+gtk_option_menu_get_props (GtkOptionMenu *option_menu,
+ GtkOptionMenuProps *props)
+{
+ GtkRequisition *indicator_size;
+ GtkBorder *indicator_spacing;
+
+ gtk_widget_style_get (GTK_WIDGET (option_menu),
+ "indicator_size", &indicator_size,
+ "indicator_spacing", &indicator_spacing,
+ NULL);
+
+ if (indicator_size)
+ {
+ props->indicator_size = *indicator_size;
+ gtk_requisition_free (indicator_size);
+ }
+ if (indicator_spacing)
+ {
+ props->indicator_spacing = *indicator_spacing;
+ gtk_border_free (indicator_spacing);
+ }
+}
+
static void
gtk_option_menu_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkOptionMenu *option_menu;
+ GtkOptionMenu *option_menu = GTK_OPTION_MENU (widget);
+ GtkOptionMenuProps props;
gint tmp;
GtkRequisition child_requisition = { 0, 0 };
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_OPTION_MENU (widget));
- g_return_if_fail (requisition != NULL);
-
- option_menu = GTK_OPTION_MENU (widget);
-
+ gtk_option_menu_get_props (option_menu, &props);
+
if (GTK_BIN (option_menu)->child && GTK_WIDGET_VISIBLE (GTK_BIN (option_menu)->child))
{
gtk_widget_size_request (GTK_BIN (option_menu)->child, &child_requisition);
requisition->width = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->xthickness) * 2 +
MAX (child_requisition.width, option_menu->width) +
- OPTION_INDICATOR_WIDTH +
- OPTION_INDICATOR_SPACING * 5 +
+ props.indicator_size.width +
+ props.indicator_spacing.left + props.indicator_spacing.right +
CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + 2);
requisition->height = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->ythickness) * 2 +
CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + 2);
tmp = (requisition->height - option_menu->height +
- OPTION_INDICATOR_HEIGHT + OPTION_INDICATOR_SPACING * 2);
+ props.indicator_size.height + props.indicator_spacing.top + props.indicator_spacing.bottom);
requisition->height = MAX (requisition->height, tmp);
}
{
GtkWidget *child;
GtkAllocation child_allocation;
-
+ GtkOptionMenuProps props;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
g_return_if_fail (allocation != NULL);
+ gtk_option_menu_get_props (GTK_OPTION_MENU (widget), &props);
+
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
child_allocation.y = (GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->ythickness) + 1;
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2 -
- OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 5 -
+ props.indicator_size.width - props.indicator_spacing.left - props.indicator_spacing.right -
CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING - 2);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2 -
CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING - 2);
child_allocation.x += CHILD_LEFT_SPACING;
- child_allocation.y += CHILD_RIGHT_SPACING;
+ child_allocation.y += CHILD_TOP_SPACING;
gtk_widget_size_allocate (child, &child_allocation);
}
GdkRectangle *area)
{
GdkRectangle button_area;
+ GtkOptionMenuProps props;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
if (GTK_WIDGET_DRAWABLE (widget))
{
+ gtk_option_menu_get_props (GTK_OPTION_MENU (widget), &props);
+
button_area.x = GTK_CONTAINER (widget)->border_width + 1;
button_area.y = GTK_CONTAINER (widget)->border_width + 1;
button_area.width = widget->allocation.width - button_area.x * 2;
gtk_paint_tab (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
area, widget, "optionmenutab",
- button_area.x + button_area.width - button_area.x -
- OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 4,
- button_area.y + (button_area.height - OPTION_INDICATOR_HEIGHT) / 2,
- OPTION_INDICATOR_WIDTH, OPTION_INDICATOR_HEIGHT);
+ button_area.x + button_area.width -
+ props.indicator_size.width - props.indicator_spacing.right -
+ widget->style->xthickness,
+ button_area.y + (button_area.height - props.indicator_size.height) / 2,
+ props.indicator_size.width, props.indicator_size.height);
if (GTK_WIDGET_HAS_FOCUS (widget))
gtk_paint_focus (widget->style, widget->window,
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "gtkintl.h"
#include "gtkpaned.h"
enum {
ARG_0,
- ARG_HANDLE_SIZE
};
static void gtk_paned_class_init (GtkPanedClass *klass);
container_class->forall = gtk_paned_forall;
container_class->child_type = gtk_paned_child_type;
- gtk_object_add_arg_type("GtkPaned::handle_size", GTK_TYPE_UINT,
- GTK_ARG_READWRITE, ARG_HANDLE_SIZE);
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("handle_size",
+ _("Handle Size"),
+ _("Width of handle"),
+ 0,
+ G_MAXINT,
+ 5,
+ G_PARAM_READABLE));
}
static GtkType
paned->handle_width = 5;
paned->handle_height = 5;
- paned->handle_size = 5;
paned->position_set = FALSE;
paned->last_allocation = -1;
paned->in_drag = FALSE;
GtkArg *arg,
guint arg_id)
{
- GtkPaned *paned = GTK_PANED (object);
-
switch (arg_id)
{
- case ARG_HANDLE_SIZE:
- gtk_paned_set_handle_size (paned, GTK_VALUE_UINT (*arg));
- break;
default:
break;
}
GtkArg *arg,
guint arg_id)
{
- GtkPaned *paned = GTK_PANED (object);
-
switch (arg_id)
{
- case ARG_HANDLE_SIZE:
- GTK_VALUE_UINT (*arg) = paned->handle_size;
- break;
default:
arg->type = GTK_TYPE_INVALID;
break;
gtk_widget_queue_resize (GTK_WIDGET (paned));
}
-void
-gtk_paned_set_handle_size (GtkPaned *paned,
- guint16 size)
-{
- g_return_if_fail (paned != NULL);
- g_return_if_fail (GTK_IS_PANED (paned));
-
- gtk_widget_queue_resize (GTK_WIDGET (paned));
-
- paned->handle_size = size;
-}
-
void
gtk_paned_compute_position(GtkPaned *paned,
gint allocation,
GdkGC *xor_gc;
GdkCursorType cursor_type;
- /*< public >*/
- guint16 handle_size;
-
/*< private >*/
guint16 handle_width;
guint16 handle_height;
gint gtk_paned_get_position (GtkPaned *paned);
void gtk_paned_set_position (GtkPaned *paned,
gint position);
-void gtk_paned_set_handle_size (GtkPaned *paned,
- guint16 size);
/* Internal function */
void gtk_paned_compute_position (GtkPaned *paned,
GtkShadowType shadow_type;
GdkRectangle restrict_area;
GdkRectangle new_area;
- gint width, height;
gint x, y;
+ gint indicator_size, indicator_spacing;
g_return_if_fail (check_button != NULL);
g_return_if_fail (GTK_IS_RADIO_BUTTON (check_button));
(state_type != GTK_STATE_PRELIGHT))
state_type = GTK_STATE_NORMAL;
+ _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
+
restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width;
restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width;
restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width);
new_area.width, new_area.height);
}
- x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
- width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
- height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
+ x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
+ y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
shadow_type = GTK_SHADOW_ETCHED_IN;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x);
+ x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x);
gtk_paint_option (widget->style, widget->window,
GTK_WIDGET_STATE (widget), shadow_type,
area, widget, "radiobutton",
- x, y, width, height);
+ x, y, indicator_size, indicator_size);
}
}
*/
#include <stdio.h>
+#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkrange.h"
#include "gtksignal.h"
widget_class->leave_notify_event = gtk_range_leave_notify;
widget_class->style_set = gtk_range_style_set;
- class->slider_width = 11;
- class->stepper_size = 11;
- class->stepper_slider_spacing = 1;
class->min_slider_size = 7;
class->trough = 1;
class->slider = 2;
_("How the range should be updated on the screen"),
GTK_TYPE_UPDATE_TYPE,
GTK_UPDATE_CONTINUOUS,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("slider_width",
+ _("Slider Width"),
+ _("Width of scrollbar or scale thumb"),
+ 0,
+ G_MAXINT,
+ 11,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("trough_border",
+ _("Trough Border"),
+ _("Width of border around range"),
+ 0,
+ G_MAXINT,
+ 2,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("stepper_size",
+ _("Stepper Size"),
+ _("Size of step buttons at ends"),
+ 0,
+ G_MAXINT,
+ 11,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("stepper_spacing",
+ _("Stepper Spacing"),
+ _("Spacing between step buttons and thumb"),
+ G_MININT,
+ G_MAXINT,
+ 1,
+ G_PARAM_READABLE));
}
static void
gint left;
gint right;
gint x;
+ gint trough_border;
g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
+
if (GTK_WIDGET_REALIZED (range))
{
gtk_range_trough_hdims (range, &left, &right);
if (should_invert (range, TRUE))
x = right - (x - left);
- move_and_update_window (range->slider, x, GTK_WIDGET (range)->style->ythickness);
+ move_and_update_window (range->slider, x, trough_border);
}
}
gint top;
gint bottom;
gint y;
+ gint trough_border;
g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
+
if (GTK_WIDGET_REALIZED (range))
{
gtk_range_trough_vdims (range, &top, &bottom);
if (should_invert (range, FALSE))
y = bottom - (y - top);
- move_and_update_window (range->slider, GTK_WIDGET (range)->style->xthickness, y);
+ move_and_update_window (range->slider, trough_border, y);
}
}
gint y,
gdouble *jump_perc)
{
- gint ythickness;
+ gint trough_border;
gint trough_width;
gint trough_height;
gint slider_x;
g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
- ythickness = GTK_WIDGET (range)->style->ythickness;
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
gtk_range_trough_hdims (range, &left, &right);
gdk_window_get_size (range->slider, &slider_length, NULL);
if (should_invert (range, TRUE))
x = (right - x) + left;
- if ((x > left) && (y > ythickness))
+ if ((x > left) && (y > trough_border))
{
gdk_window_get_size (range->trough, &trough_width, &trough_height);
-
- if ((x < right) && (y < (trough_height - ythickness)))
+
+ if ((x < right) && (y < (trough_height - trough_border)))
{
if (jump_perc)
{
gint y,
gdouble *jump_perc)
{
- gint xthickness;
+ gint trough_border;
gint trough_width;
gint trough_height;
gint slider_y;
g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
- xthickness = GTK_WIDGET (range)->style->xthickness;
-
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
+
gtk_range_trough_vdims (range, &top, &bottom);
gdk_window_get_size (range->slider, NULL, &slider_length);
bottom += slider_length;
if (should_invert (range, FALSE))
y = (bottom - y) + top;
- if ((x > xthickness) && (y > top))
+ if ((x > trough_border) && (y > top))
{
gdk_window_get_size (range->trough, &trough_width, &trough_height);
- if ((x < (trough_width - xthickness) && (y < bottom)))
+ if ((x < (trough_width - trough_border) && (y < bottom)))
{
if (jump_perc)
{
gint tmp_width;
gint tleft;
gint tright;
+ gint stepper_spacing;
+ gint trough_border;
g_return_if_fail (range != NULL);
gdk_window_get_size (range->trough, &trough_width, NULL);
gdk_window_get_size (range->slider, &slider_length, NULL);
- tleft = GTK_WIDGET (range)->style->xthickness;
- tright = trough_width - slider_length - GTK_WIDGET (range)->style->xthickness;
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, &stepper_spacing);
+
+ tleft = trough_border;
+ tright = trough_width - slider_length - trough_border;
if (range->step_back)
{
gdk_window_get_size (range->step_back, &tmp_width, NULL);
- tleft += (tmp_width + RANGE_CLASS (range)->stepper_slider_spacing);
+ tleft += (tmp_width + stepper_spacing);
}
if (range->step_forw)
{
gdk_window_get_size (range->step_forw, &tmp_width, NULL);
- tright -= (tmp_width + RANGE_CLASS (range)->stepper_slider_spacing);
+ tright -= (tmp_width + stepper_spacing);
}
if (left)
gint tmp_height;
gint ttop;
gint tbottom;
+ gint stepper_spacing;
+ gint trough_border;
g_return_if_fail (range != NULL);
+ _gtk_range_get_props (range, NULL, &trough_border, NULL, &stepper_spacing);
+
gdk_window_get_size (range->trough, NULL, &trough_height);
gdk_window_get_size (range->slider, NULL, &slider_length);
- ttop = GTK_WIDGET (range)->style->ythickness;
- tbottom = trough_height - slider_length - GTK_WIDGET (range)->style->ythickness;
+ ttop = trough_border;
+ tbottom = trough_height - slider_length - trough_border;
if (range->step_back)
{
gdk_window_get_size (range->step_back, NULL, &tmp_height);
- ttop += (tmp_height + RANGE_CLASS (range)->stepper_slider_spacing);
+ ttop += (tmp_height + stepper_spacing);
}
if (range->step_forw)
{
gdk_window_get_size (range->step_forw, NULL, &tmp_height);
- tbottom -= (tmp_height + RANGE_CLASS (range)->stepper_slider_spacing);
+ tbottom -= (tmp_height + stepper_spacing);
}
if (top)
}
}
}
+
+void
+_gtk_range_get_props (GtkRange *range,
+ gint *slider_width,
+ gint *trough_border,
+ gint *stepper_size,
+ gint *stepper_spacing)
+{
+ GtkWidget *widget = GTK_WIDGET (range);
+
+
+ if (slider_width)
+ gtk_widget_style_get (widget, "slider_width", slider_width, NULL);
+
+ if (trough_border)
+ gtk_widget_style_get (widget, "trough_border", trough_border, NULL);
+
+ if (stepper_size)
+ gtk_widget_style_get (widget, "stepper_size", stepper_size, NULL);
+
+ if (stepper_spacing)
+ gtk_widget_style_get (widget, "stepper_spacing", stepper_spacing, NULL);
+}
+
{
GtkWidgetClass parent_class;
- gint slider_width;
- gint stepper_size;
- gint stepper_slider_spacing;
gint min_slider_size;
guint8 trough;
gint xdelta,
gint ydelta);
+void _gtk_range_get_props (GtkRange *range,
+ gint *slider_width,
+ gint *trough_border,
+ gint *stepper_size,
+ gint *stepper_spacing);
#ifdef __cplusplus
}
*/
#include <math.h>
-#include "gtkcontainer.h"
+#include "gtkintl.h"
#include "gtkscale.h"
enum {
range_class->draw_background = gtk_scale_draw_background;
- class->slider_length = 31;
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("slider_length",
+ _("Slider Length"),
+ _("Length of scale's slider"),
+ 0,
+ G_MAXINT,
+ 31,
+ G_PARAM_READABLE));
class->value_spacing = 2;
class->draw_value = NULL;
}
{
GtkRangeClass parent_class;
- gint slider_length;
gint value_spacing;
void (* draw_value) (GtkScale *scale);
GtkShadowType shadow_type;
GtkStateType state_type;
gint width, height;
+ gboolean interior_focus;
gint x, y;
button = GTK_BUTTON (widget);
if (GTK_WIDGET_DRAWABLE (widget))
{
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
x = 0;
y = 0;
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
y += DEFAULT_TOP_POS;
}
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
x += 1;
y += 1;
if (GTK_WIDGET_HAS_FOCUS (widget))
{
- x -= 1;
- y -= 1;
- width += 2;
- height += 2;
+ if (interior_focus)
+ {
+ x += widget->style->xthickness + 1;
+ y += widget->style->xthickness + 1;
+ width -= 2 * (widget->style->xthickness + 1);
+ height -= 2 * (widget->style->ythickness + 1);
+ }
+ else
+ {
+ x -= 1;
+ y -= 1;
+ width += 2;
+ height += 2;
+ }
gtk_paint_focus (widget->style, widget->window,
area, widget, "togglebutton",
gtk_vpaned_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child_requisition;
+ gint handle_size;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_VPANED (widget));
- g_return_if_fail (requisition != NULL);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
- paned = GTK_PANED (widget);
requisition->width = 0;
requisition->height = 0;
requisition->height += child_requisition.height;
}
- requisition->height += GTK_CONTAINER (paned)->border_width * 2 + paned->handle_size;
+ requisition->height += GTK_CONTAINER (paned)->border_width * 2 + handle_size;
requisition->width += GTK_CONTAINER (paned)->border_width * 2;
}
gtk_vpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child1_requisition;
GtkRequisition child2_requisition;
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
gint border_width;
+ gint handle_size;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_VPANED (widget));
- g_return_if_fail (allocation != NULL);
-
widget->allocation = *allocation;
- paned = GTK_PANED (widget);
+
border_width = GTK_CONTAINER (widget)->border_width;
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (paned->child1)
gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
child2_requisition.height = 0;
gtk_paned_compute_position (paned,
- MAX (1, (gint) widget->allocation.height
- - (gint) paned->handle_size
+ MAX (1, widget->allocation.height
+ - handle_size
- 2 * border_width),
child1_requisition.height,
child2_requisition.height);
paned->handle_xpos = border_width;
paned->handle_ypos = paned->child1_size + border_width;
paned->handle_width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
- paned->handle_height = paned->handle_size;
+ paned->handle_height = handle_size;
if (GTK_WIDGET_REALIZED(widget))
{
paned->handle_xpos,
paned->handle_ypos,
paned->handle_width,
- paned->handle_size);
+ handle_size);
}
child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
GtkWidget *widget;
GdkGCValues values;
guint16 ypos;
+ gint handle_size;
widget = GTK_WIDGET (paned);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
+
if (!paned->xor_gc)
{
values.function = GDK_INVERT;
GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
ypos = paned->child1_size
- + GTK_CONTAINER (paned)->border_width + paned->handle_size / 2;
+ + GTK_CONTAINER (paned)->border_width + handle_size / 2;
gdk_draw_line (widget->window, paned->xor_gc,
0,
gtk_vpaned_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
+ gint handle_size;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
-
- paned = GTK_PANED (widget);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->in_drag &&
(event->window == paned->handle) && (event->button == 1))
| GDK_BUTTON1_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK, NULL, NULL,
event->time);
- paned->child1_size += event->y - paned->handle_size / 2;
+ paned->child1_size += event->y - handle_size / 2;
paned->child1_size = CLAMP (paned->child1_size, 0,
widget->allocation.height -
- paned->handle_size -
+ handle_size -
2 * GTK_CONTAINER (paned)->border_width);
gtk_vpaned_xor_line(paned);
gtk_vpaned_motion (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkPaned *paned;
+ GtkPaned *paned = GTK_PANED (widget);
gint y;
+ gint handle_size;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
+ gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (event->is_hint || event->window != widget->window)
gtk_widget_get_pointer (widget, NULL, &y);
else
y = event->y;
- paned = GTK_PANED (widget);
-
if (paned->in_drag)
{
- gint size = y - GTK_CONTAINER(paned)->border_width - paned->handle_size / 2;
+ gint size = y - GTK_CONTAINER(paned)->border_width - handle_size / 2;
gtk_vpaned_xor_line (paned);
paned->child1_size = CLAMP (size, paned->min_position, paned->max_position);
GdkWindowAttr attributes;
gint attributes_mask;
gint x, y, w, h;
+ gint slider_width, slider_length;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCALE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
+
+ _gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
+ gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
- attributes.width = RANGE_CLASS (range)->slider_width;
- attributes.height = SCALE_CLASS (range)->slider_length;
+ attributes.width = slider_width;
+ attributes.height = slider_length;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
gtk_vscale_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkScale *scale;
- gint value_width, value_height;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_VSCALE (widget));
- g_return_if_fail (requisition != NULL);
+ GtkScale *scale = GTK_SCALE (widget);
+ gint slider_width, slider_length, trough_border;
- scale = GTK_SCALE (widget);
-
- requisition->width = (RANGE_CLASS (scale)->slider_width +
- widget->style->ythickness * 2);
- requisition->height = (SCALE_CLASS (scale)->slider_length +
- widget->style->xthickness) * 2;
+ _gtk_range_get_props (GTK_RANGE (scale),
+ &slider_width, &trough_border, NULL, NULL);
+ gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
+
+ requisition->width = (slider_width + trough_border * 2);
+ requisition->height = (slider_length + trough_border) * 2;
if (scale->draw_value)
{
+ gint value_width, value_height;
gtk_scale_get_value_size (scale, &value_width, &value_height);
if ((scale->value_pos == GTK_POS_LEFT) ||
gint *w,
gint *h)
{
- GtkWidget *widget;
- GtkScale *scale;
+ GtkWidget *widget = GTK_WIDGET (vscale);
+ GtkScale *scale = GTK_SCALE (vscale);
gint value_width, value_height;
+ gint slider_width, trough_border;
- g_return_if_fail (vscale != NULL);
- g_return_if_fail (GTK_IS_VSCALE (vscale));
- g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
-
- widget = GTK_WIDGET (vscale);
- scale = GTK_SCALE (vscale);
-
- *w = (RANGE_CLASS (scale)->slider_width +
- widget->style->xthickness * 2);
+ _gtk_range_get_props (GTK_RANGE (scale),
+ &slider_width, &trough_border, NULL, NULL);
+
+ *w = (slider_width + trough_border * 2);
*h = widget->allocation.height;
if (scale->draw_value)
{
GtkWidget *widget;
GtkScale *scale;
+ gint slider_width, trough_border;
gint tx, ty, twidth, theight;
GValue *value,
GParamSpec *pspec);
static void gtk_vscrollbar_realize (GtkWidget *widget);
+static void gtk_vscrollbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
static void gtk_vscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_vscrollbar_draw_step_forw (GtkRange *range);
GtkScrollType *scroll,
GtkTroughType *pos);
-
GtkType
gtk_vscrollbar_get_type (void)
{
gobject_class->get_property = gtk_vscrollbar_get_property;
widget_class->realize = gtk_vscrollbar_realize;
+ widget_class->size_request = gtk_vscrollbar_size_request;
widget_class->size_allocate = gtk_vscrollbar_size_allocate;
range_class->draw_step_forw = gtk_vscrollbar_draw_step_forw;
static void
gtk_vscrollbar_init (GtkVScrollbar *vscrollbar)
{
- GtkWidget *widget;
- GtkRequisition *requisition;
-
- widget = GTK_WIDGET (vscrollbar);
- requisition = &widget->requisition;
-
- requisition->width = (RANGE_CLASS (widget)->slider_width +
- widget->style->xthickness * 2);
- requisition->height = (RANGE_CLASS (widget)->min_slider_size +
- RANGE_CLASS (widget)->stepper_size +
- RANGE_CLASS (widget)->stepper_slider_spacing +
- widget->style->ythickness) * 2;
}
GtkWidget*
GtkRange *range;
GdkWindowAttr attributes;
gint attributes_mask;
+ gint slider_width;
+ gint stepper_size;
+ gint trough_border;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
+ _gtk_range_get_props (range, &slider_width, &trough_border,
+ &stepper_size, NULL);
+
attributes.x = widget->allocation.x + (widget->allocation.width - widget->requisition.width) / 2;
attributes.y = widget->allocation.y;
attributes.width = widget->requisition.width;
range->trough = widget->window;
gdk_window_ref (range->trough);
- attributes.x = widget->style->xthickness;
- attributes.y = widget->style->ythickness;
- attributes.width = RANGE_CLASS (widget)->stepper_size;
- attributes.height = RANGE_CLASS (widget)->stepper_size;
+ attributes.x = trough_border;
+ attributes.y = trough_border;
+ attributes.width = stepper_size;
+ attributes.height = stepper_size;
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.y = (widget->allocation.height -
- widget->style->ythickness -
- RANGE_CLASS (widget)->stepper_size);
+ trough_border -
+ stepper_size);
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
- attributes.x = widget->style->ythickness;
+ attributes.x = trough_border;
attributes.y = 0;
- attributes.width = RANGE_CLASS (widget)->slider_width;
+ attributes.width = slider_width;
attributes.height = RANGE_CLASS (widget)->min_slider_size;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
gdk_window_show (range->step_back);
}
+static void
+gtk_vscrollbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ gint slider_width;
+ gint trough_border;
+ gint stepper_size;
+ gint stepper_spacing;
+
+ GtkRange *range = GTK_RANGE (widget);
+
+ _gtk_range_get_props (range, &slider_width, &trough_border,
+ &stepper_size, &stepper_spacing);
+
+ requisition->width = (slider_width +
+ trough_border * 2);
+ requisition->height = (RANGE_CLASS (widget)->min_slider_size +
+ stepper_size +
+ stepper_spacing +
+ trough_border) * 2;
+}
+
static void
gtk_vscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkRange *range;
+ gint trough_border;
+ gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
{
range = GTK_RANGE (widget);
+ _gtk_range_get_props (range, NULL, &trough_border,
+ &stepper_size, NULL);
+
gdk_window_move_resize (range->trough,
allocation->x + (allocation->width - widget->requisition.width) / 2,
allocation->y,
widget->requisition.width, allocation->height);
gdk_window_move_resize (range->step_back,
- widget->style->xthickness,
- widget->style->ythickness,
- widget->requisition.width - widget->style->xthickness * 2,
- RANGE_CLASS (widget)->stepper_size);
+ trough_border,
+ trough_border,
+ widget->requisition.width - trough_border * 2,
+ stepper_size);
gdk_window_move_resize (range->step_forw,
- widget->style->xthickness,
- allocation->height - widget->style->ythickness -
- RANGE_CLASS (widget)->stepper_size,
- widget->requisition.width - widget->style->xthickness * 2,
- RANGE_CLASS (widget)->stepper_size);
+ trough_border,
+ allocation->height - trough_border -
+ stepper_size,
+ widget->requisition.width - trough_border * 2,
+ stepper_size);
_gtk_range_slider_update (GTK_RANGE (widget));
}
gint step_back_y;
gint step_back_height;
gint step_forw_y;
+ gint stepper_spacing;
gint slider_width;
gint slider_height;
gint top, bottom;
{
range = GTK_RANGE (vscrollbar);
+ _gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
+
gdk_window_get_size (range->step_back, NULL, &step_back_height);
gdk_window_get_position (range->step_back, NULL, &step_back_y);
gdk_window_get_position (range->step_forw, NULL, &step_forw_y);
top = (step_back_y +
step_back_height +
- RANGE_CLASS (vscrollbar)->stepper_slider_spacing);
- bottom = step_forw_y - RANGE_CLASS (vscrollbar)->stepper_slider_spacing;
+ stepper_spacing);
+ bottom = step_forw_y - stepper_spacing;
height = bottom - top;
if ((range->adjustment->page_size > 0) &&
#include <locale.h>
#include "gtkcontainer.h"
#include "gtkiconfactory.h"
+#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkrc.h"
#include "gtkselection.h"
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
widget_signals[SIZE_REQUEST] =
- gtk_signal_new ("size_request",
- GTK_RUN_FIRST,
- GTK_CLASS_TYPE (object_class),
- GTK_SIGNAL_OFFSET (GtkWidgetClass, size_request),
- gtk_marshal_VOID__BOXED,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_REQUISITION | G_VALUE_NOCOPY_CONTENTS);
+ g_signal_newc ("size_request",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkWidgetClass, size_request),
+ NULL, NULL,
+ gtk_marshal_VOID__BOXED,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SIZE_ALLOCATE] =
gtk_signal_new ("size_allocate",
GTK_RUN_FIRST,
gtk_marshal_BOOLEAN__BOXED,
GTK_TYPE_BOOL, 1,
GTK_TYPE_GDK_EVENT);
+
widget_signals[POPUP_MENU] =
gtk_signal_new ("popup_menu",
GTK_RUN_LAST | GTK_RUN_ACTION,
gtk_binding_entry_add_signal (binding_set, GDK_Menu, 0,
"popup_menu", 0);
+
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boolean ("interior_focus",
+ _("Interior Focus"),
+ _("Whether to draw the focus indicator inside widgets."),
+ FALSE,
+ G_PARAM_READABLE));
}
static void
{
# xthickness = 20
GtkSpinButton::shadow_type = etched-out
+ GtkOptionMenu::indicator_spacing = { 10, 10, 10, 10 }
}
class "GtkWidget" style "global-style-properties"
{
# xthickness = 20
GtkSpinButton::shadow_type = etched-out
+ GtkOptionMenu::indicator_spacing = { 10, 10, 10, 10 }
}
class "GtkWidget" style "global-style-properties"